package com.shushan.home;

import android.app.Activity;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;

import com.android.permission.rom.RomType;
import com.android.permission.rom.RomUtils;
import com.shushan.accessibility.PermissionAccessOpenActivity;
import com.shushan.accessibility.PermissionHandOpenActivity;
import com.shushan.base.Constants;
import com.shushan.base.ScreenManager;
import com.shushan.shushanbao.R;
import com.shushan.util.SharedPreferencesUtils;
import com.shushan.util.UmengEventUtil;

import static com.android.permission.rom.RomType.FUNTOUCHOS_ROM;

/**
 * @ClassName: ParentGuideActivity
 * @Desciption: 家长模式引导
 * @author: yichaohua
 * @date: 2018-09-06
 */
public class ParentGuideActivity extends Activity implements View.OnClickListener {

    private static final String TAG = "ControlGuideActivity";

    private RelativeLayout guideLayout;
    private ImageView guideImg;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.parent_guide_activity);

        ScreenManager sm = new ScreenManager();
        sm.setStatusBar(true,this);

        initView();
    }

    @Override
    protected void onResume() {
        super.onResume();

        UmengEventUtil.onResume(this); // 基础指标统计，不能遗漏

        SharedPreferencesUtils.setBooleanDate(Constants.APP_NOT_FIRST_PARENT_SHAREPREFERS_KEY,true);
    }

    @Override
    protected void onPause() {
        super.onPause();

        UmengEventUtil.onPause(this); // 基础指标统计，不能遗漏
    }

    private void initView() {
        guideLayout = findViewById(R.id.control_guide_layout);
        guideLayout.setOnClickListener(this);
        guideImg = findViewById(R.id.control_guide_img);
        guideImg.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.control_guide_layout:
                finish();
                break;
            case R.id.control_guide_img:
                finish();

                RomType romType = RomUtils.getRomType(this);
                Log.i(TAG,"romType=" + romType + " Build.VERSION.SDK_INT=" + Build.VERSION.SDK_INT);
                if(romType == FUNTOUCHOS_ROM && Build.VERSION.SDK_INT >= Build.VERSION_CODES.N){
                    startActivity(new Intent(this,PermissionHandOpenActivity.class));
                }else {
                    startActivity(new Intent(this,PermissionAccessOpenActivity.class));
                }


                break;
            default:
                break;
        }
    }
}
